package com.order.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.order.entity.Person;
import com.order.service.PersonService;

/**
 * 人员信息控制器
 * @author xdc
 * @date 2014-11-6 下午03:50:29
 */
@Controller
@RequestMapping(value="PersonController")
public class PersonController {

	@Autowired
	private PersonService personService;
	
	/**
	 * 获得人员信息列表
	 * @author xdc
	 * @date 2014-11-6 下午04:11:45
	 * @param model
	 * @return
	 */
	@RequestMapping(value="getPersonList")
	public ModelAndView getPersonList(ModelAndView model){
		
		List<Person> list = personService.getPersonList();
		
		model.addObject("list", list);
		model.setViewName("person/person_list");
		
		return model;
	}
	
	/**
	 * AJAX 通过id删除人员信息
	 * @author xdc
	 * @date 2014-11-6 下午05:23:29
	 * @param id		人员id
	 * @return
	 */
	@RequestMapping(value="deletePersonById")
	@ResponseBody
	public Map<String, Object> deletePersonById(String id){
		
		// 模拟删除
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("result", "success");
		
		return map;
	}
}
